﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SLIC.Models.UserAdministration.UserDataModel>" %>


<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    UserDetail
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<%
        /// <summary>
        /// 
        ///  <title>SLIC</title>
        ///  <description>User Details page for View user details </description>
        ///  <copyRight>Copyright (c) 2011</copyRight>
        ///  <company>IronOne Technologies (Pvt)Ltd</company>
        ///  <createdOn>2011-08-05</createdOn>
        ///  <author></author>
        ///  <modification>
        ///     <modifiedBy></modifiedBy>
        ///      <modifiedDate></modifiedDate>
        ///     <description></description>
        ///  </modification>
        ///
        /// </summary>                                                                                 
    %>


    <script type="text/javascript">
        function ShowCSRCode(item) {
            //  alert('asdasd');
            if (item == "Technical Officer") {
                //    alert('in');
                $('#trCSRCode').show();
            }
            else
                $('#trCSRCode').hide();
            //  alert($('#trCSRCode') + item);
        }

        // alert($('#ddlUserRole').val());
  
    </script>
    <h2>
        <% bool isEdit = Model != null && Model.UserId != 0; %>
        <%if (isEdit)
          { %>
        User details of
        <%:Model.username %>
        <%}
          else
          { %>
        Create User
        <%--(<%:ViewData["roleName"]%>)--%>
        <%} %>
    </h2>
    <% using (Html.BeginForm((isEdit) ? "UpdateUser" : "AddUser", "UserAdministration", new
       {
           existingRole =%>
    <%(isEdit) ? Model.roleName : null %>
    <%}))
       {
    %>
    <%
           ModelState err = ViewContext.ViewData.ModelState["err"];
           SLIC.Controllers.GenException result = null;
           if (err != null)
           {
               result = (SLIC.Controllers.GenException)err.Errors.ElementAt(0).Exception;
    %>
    <div class="txtError" style="width: 456px">
        <%: result.Message%>
    </div>
    <%  }	%>
    <%--<%:Model.roleName %>--%>
    <div id="innerContainer" style="width: 400px; padding-top: 10px;">
        <fieldset style="width: 95%">
            <%: Html.ValidationSummary(true) %>
            <%:Html.HiddenFor(model => model.UserId) %>
            <%:Html.HiddenFor(model => model.OldPassword) %>
            <%:Html.HiddenFor(model => model.isAgent) %>
            <%--      <%if (!isEdit)
              {%>
            <%:Html.HiddenFor(model => model.roleName)%>
            <%} %>--%>
            <%:Html.HiddenFor(model => model.isAgent)%>
            <table border="0" cellspacing="0" cellpadding="0" style="color: #000">
                <tr class="odd" style="border: solid 1px #aaa;">
                    <td class="normaltdsForm" style="border-top: solid 1px #aaa;">
                        User Name
                    </td>
                    <td class="colontdsForm">
                        :
                    </td>
                    <td class="normaltdsForm txtErrorSmall" style="border-top: solid 1px #aaa;">
                        <%if (isEdit)
                          { %>
                        <%: Html.TextBoxFor(model => model.username,  new { @readonly = "readonly" })%>
                        <%}
                          else
                          { %>
                        <%: Html.TextBoxFor(model => model.username,  new { OnKeyPress = "return AlphanumericValidation(event);"  } )%>
                        <%} %>
                        <font color="red">
                            <%: Html.ValidationMessageFor(model => model.username) %></font>
                    </td>
                </tr>
                <tr class="even" style="border: solid 1px #aaa;">
                    <td class="normaltdsForm" style="border-top: solid 1px #aaa;">
                        First Name
                    </td>
                    <td class="colontdsForm">
                        :
                    </td>
                    <td class="normaltdsForm txtErrorSmall" style="border-top: solid 1px #aaa;">
                        <%: Html.TextBoxFor(model => model.firstName, new { OnKeyPress = "return AlphanumericValidation(event);" })%>
                        <font color="red">
                            <%: Html.ValidationMessageFor(model => model.firstName) %></font>
                    </td>
                </tr>
                <tr class="odd" style="border: solid 1px #aaa;">
                    <td class="normaltdsForm" style="border-top: solid 1px #aaa;">
                        Last Name
                    </td>
                    <td class="colontdsForm">
                        :
                    </td>
                    <td class="normaltdsForm txtErrorSmall" style="border-top: solid 1px #aaa;">
                        <%: Html.TextBoxFor(model => model.lastname, new { OnKeyPress = "return AlphanumericValidation(event);" })%>
                        <font color="red">
                            <%: Html.ValidationMessageFor(model => model.lastname) %></font>
                    </td>
                </tr>
                <tr class="even" style="border: solid 1px #aaa;">
                    <td class="normaltdsForm" style="border-top: solid 1px #aaa;">
                        Email
                    </td>
                    <td class="colontdsForm">
                        :
                    </td>
                    <td class="normaltdsForm txtErrorSmall" style="border-top: solid 1px #aaa;">
                        <%: Html.TextBoxFor(model => model.email, new { OnKeyPress = "return AlphanumericValidation(event);" })%>
                        <font color="red">
                            <%: Html.ValidationMessageFor(model => model.email) %></font>
                    </td>
                </tr>
                <%if (!isEdit)
                  {%>
                <tr class="odd" style="border: solid 1px #aaa;">
                    <td class="normaltdsForm" style="border-top: solid 1px #aaa;">
                        Password
                    </td>
                    <td class="colontdsForm">
                        :
                    </td>
                    <td class="normaltdsForm txtErrorSmall" style="border-top: solid 1px #aaa;">
                        <%: Html.PasswordFor(model => model.password, new { OnKeyPress = "return AlphanumericValidation(event);" })%>
                        <%--            <%: Html.PasswordFor(model => model.password, (isEdit) ? new { value = Model.password } : null)%>--%>
                        <font color="red">
                            <%: Html.ValidationMessageFor(model => model.password) %></font>
                        <%--   <%if(Model!=null){ %>
                        <%: Html.PasswordFor(model => model.password,new {type="password",value=Model.password}) %>
                        <%}else{%>
                        <%: Html.PasswordFor(model => model.password,new {type="password"}) %>
                        <%} %>
                        <%: Html.ValidationMessageFor(model => model.password) %>--%>
                    </td>
                </tr>
                <tr class="even" style="border: solid 1px #aaa;">
                    <td class="normaltdsForm" style="border-top: solid 1px #aaa;">
                        Confirm Password
                    </td>
                    <td class="colontdsForm">
                        :
                    </td>
                    <td class="normaltdsForm txtErrorSmall" style="border-top: solid 1px #aaa;">
                        <%: Html.PasswordFor(model => model.ConfirmPassword, new { OnKeyPress = "return AlphanumericValidation(event);" })%>
                        <%--  <%: Html.PasswordFor(model => model.ConfirmPassword, (isEdit) ? new { value = Model.ConfirmPassword } : null)%>--%>
                        <font color="red">
                            <%: Html.ValidationMessageFor(model => model.ConfirmPassword)%></font>
                        <%--        <%if(Model!=null){ %>
                        <%: Html.PasswordFor(model => model.ConfirmPassword,new {type="password",value=Model.ConfirmPassword}) %>
                        <%}else{%>
                        <%: Html.PasswordFor(model => model.ConfirmPassword,new {type="password"}) %>
                        <%} %>
                        <%: Html.ValidationMessageFor(model => model.ConfirmPassword) %>--%>
                    </td>
                </tr>
                <%} %>
                <tr class="odd" style="border: solid 1px #aaa;">
                    <td class="normaltdsForm" style="border-top: solid 1px #aaa;">
                        User Role
                    </td>
                    <td class="colontdsForm">
                        :
                    </td>
                    <td class="normaltdsForm txtErrorSmall" style="border-top: solid 1px #aaa;">
                        <%--<%: Html.DropDownListFor(model => model.roleName, (SelectList)ViewData["Roles"],(isEdit)?null:new {disabled="disabled"})%>--%>
                        <%: Html.DropDownListFor(model => model.roleName, (SelectList)ViewData["Roles"], new { @onchange = "ShowCSRCode(this.value)", id = "ddlUserRole" })%>
                        <%--    <%: Html.ValidationMessageFor(model => model.roles[0]) %--%>
                    </td>
                </tr>
                <%if (Model != null)
                  {%>
                <tr style="border: solid 1px #aaa;" id="trCSRCode" class="<%=(Model.isAgent)?"even":"even HideCSR"%>">
                    <td class="normaltdsForm" style="border-top: solid 1px #aaa;">
                        CSR Code
                    </td>
                    <td class="colontdsForm">
                        :
                    </td>
                    <td class="normaltdsForm txtErrorSmall" style="border-top: solid 1px #aaa;">
                        <%: Html.TextBoxFor(model => model.CSRCode, new { OnKeyPress = "return AlphanumericValidation(event);" })%>
                        <font color="red">
                            <%: Html.ValidationMessageFor(model => model.CSRCode) %></font>
                        <%--       <%: Html.DropDownList("ROLE", (SelectList)ViewData["Roles"] )%>--%>
                    </td>
                </tr>
                <%} %>
            </table>
        </fieldset>
    </div>
    <br />
    <div class="buttons">
        <input type="submit" value='<%= ((isEdit) ? "Update":"Create") %>' class="button"
            <% if(ViewData["isLocked"]!=null && Convert.ToBoolean(ViewData["isLocked"])){%>
            disabled="disabled" <%}%> />
        <input type="submit" onclick="parent.location='<%: Url.Action("ViewUsers", "UserAdministration",new{roleName=ViewData["roleName"]}) %>';return false;"
            value="All Users" class="button" />
    </div>
    <% } %>
    <%-- <br />
    <div>
        <%: Html.ActionLink("All Users", "ViewUsers","UserAdministration") %>
    </div>--%>
    <script type="text/javascript">
        ShowCSRCode($("#ddlUserRole").val());
        //  alert($("#ddlUserRole").val());
    </script>
</asp:Content>
